package com.thingsgrid.basicInterface.vo;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.thingsgrid.basicInterface.entity.BasicInterface;
import com.thingsgrid.basicInterface.entity.BasicInterfaceType;
import lombok.Data;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

@Data
public class TypeTree {

	@JsonSerialize(using = ToStringSerializer.class)
	private Long id;

	private String name;

	private boolean choose = false;

	private List<TypeChild> children = new ArrayList<TypeChild>() ;

	public TypeTree(BasicInterfaceType type){
		this.id = type.getId();
		this.name = type.getTypeName();
	}


	public TypeTree(BasicInterfaceType type, Collection<Long> ids){
		if( !ids.isEmpty() && ids.contains(type.getId())){
			this.choose = true;
		}
		this.id = type.getId();
		this.name = type.getTypeName();
	}
}

